Document

public interface Document implements Node

An HTML DOM document.

Properties

Link copied to clipboard
public final Element documentElement
public final Element documentElement

Returns the document HTML element that usually represents HTML tag, if any.

Link copied to clipboard
public final Element focusedElement
public final Element focusedElement

Returns the currently focused element in the document, if any.

Link copied to clipboard
public final Node nextSibling
public final Node nextSibling

Returns the next node in the document tree, if any.

Link copied to clipboard
public final Node parent
public final Node parent

Returns the parent of this node, if any.

Link copied to clipboard
public final Node previousSibling
public final Node previousSibling

Returns the previous node in the document tree, if any.

Link copied to clipboard
public final XPathExpression xPath
public final XPathExpression xPath

Returns XPathExpression that represents path to this Node, or an empty expression if it is not available.

Functions

Link copied to clipboard
public abstract void addEventListener(EventType eventType, Observer<Event> listener, boolean useCapture)
Adds the given listener to the event target.
Link copied to clipboard
public abstract boolean appendChild(Node childNode)
Adds the given node as a child of the current node to the end of its children list.
Link copied to clipboard
public abstract String baseUri()
Returns a string that represents the <base> element's href attribute if one is present.
Link copied to clipboard
public abstract List<Node> children()
Returns an immutable list of all children of this node.
Link copied to clipboard
public abstract void click()
Simulates a click on the node.
Link copied to clipboard
public abstract void close()
Closes this node.
Link copied to clipboard
public abstract Set<DocumentPosition> compareDocumentPosition(Node otherNode)
Compares position of the current node against another node in a DOM tree.
Link copied to clipboard
public abstract CustomEvent createCustomEvent(EventType eventType, CustomEventParams params)
Creates and returns a new CustomEvent object with the given eventType and params.
Link copied to clipboard
public abstract Element createElement(String tagName)
Creates and returns a new DOM element with the given tagName.
Link copied to clipboard
public abstract Event createEvent(EventType eventType, EventParams params)
Creates and returns a new Event object with the given eventType and params.
Link copied to clipboard
public abstract KeyEvent createKeyDownEvent(KeyEventParams params)
Creates a new KeyEvent instance with the KEY_DOWN event type and the given params.
Link copied to clipboard
public abstract KeyEvent createKeyPressEvent(KeyEventParams params)
Creates a new KeyEvent instance with the KEY_PRESS event type and the given params.
Link copied to clipboard
public abstract KeyEvent createKeyUpEvent(KeyEventParams params)
Creates a new KeyEvent instance with the KEY_UP event type and the given params.
Link copied to clipboard
public abstract MouseEvent createMouseEvent(EventType eventType, MouseEventParams params)
Creates and returns a new MouseEvent object with the given eventType and params.
Link copied to clipboard
public abstract Node createTextNode()
Creates and returns a Node object representing a new text node with an empty node value.
public abstract Node createTextNode(String text)
Creates and returns a Node object representing a new text node initialized with the given text value.
Link copied to clipboard
public abstract WheelEvent createWheelEvent(EventType eventType, WheelEventParams params)
Creates and returns a new WheelEvent object with the given eventType and params.
Link copied to clipboard
public abstract boolean dispatch(Event event)
Dispatches the given event at the current event target.
Link copied to clipboard
public abstract Document document()
Returns the Document instance of this node.
Link copied to clipboard
public abstract Optional<Element> documentElement()
Returns an Optional that contains the document HTML element that usually represents HTML tag, otherwise an empty Optional if the document element is not available.
Link copied to clipboard
public abstract XPathResult evaluate(String expression)
Evaluates the given XPath expression for the node and returns the XPathResult of the ANY type.
public abstract XPathResult evaluate(String expression, XPathResultType type)
Evaluates the given XPath expression for the node and returns the XPathResult object of the given type.
Link copied to clipboard
public final XPathResult evaluate(XPathExpression expression)
public final XPathResult evaluate(XPathExpression expression)

Evaluates the given expression for the node and returns XPathResult of the XPathResultType.ANY type.

public final XPathResult evaluate(XPathExpression expression, XPathResultType type)
public final XPathResult evaluate(XPathExpression expression, XPathResultType type)

Evaluates the given expression for the node and returns XPathResult of the given type.

Link copied to clipboard
public abstract List<Observer<Event>> eventListeners(EventType eventType, boolean useCapture)
Returns the immutable list of event listeners that listen events of the given eventType in a phase that corresponds the given useCapture.
Link copied to clipboard
public final Element findByClassName(String className)
public final Element findByClassName(String className)

Returns the first Element found in the current search context by the given className, if any.

Link copied to clipboard
public final Element findByCssSelector(String cssSelector)
public final Element findByCssSelector(String cssSelector)

Returns the first Element found in the current search context by the given cssSelector, if any.

Link copied to clipboard
public final Element findById(String id)
public final Element findById(String id)

Returns the first Element found in the current search context by the given id, if any.

Link copied to clipboard
public final Element findByName(String name)
public final Element findByName(String name)

Returns the first Element found in the current search context by the given name, if any.

Link copied to clipboard
public final Element findByTagName(String tagName)
public final Element findByTagName(String tagName)

Returns the first Element found in the current search context by the given tagName, if any.

Link copied to clipboard
public abstract Optional<Element> findElementByClassName(String className)
Returns the first Element object found in the current search context by the given className.
Link copied to clipboard
public abstract Optional<Element> findElementByCssSelector(String cssSelector)
Returns the first Element object found in the current search context by the given cssSelector.
Link copied to clipboard
public abstract Optional<Element> findElementById(String id)
Returns the first Element object found in the current search context by the given id.
Link copied to clipboard
public abstract Optional<Element> findElementByName(String name)
Returns the first Element object found in the current search context by the given name.
Link copied to clipboard
public abstract Optional<Element> findElementByTagName(String tagName)
Returns the first Element object found in the current search context by the given tagName.
Link copied to clipboard
public abstract List<Element> findElementsByClassName(String className)
Returns an immutable list of the Element objects found in the current search context by the given className.
Link copied to clipboard
public abstract List<Element> findElementsByCssSelector(String cssSelector)
Returns an immutable list of the Element objects found in the current search context by the given cssSelector.
Link copied to clipboard
public abstract List<Element> findElementsById(String id)
Returns an immutable list of the Element objects found in the current search context by the given id.
Link copied to clipboard
public abstract List<Element> findElementsByName(String name)
Returns an immutable list of the Element objects found in the current search context by the given name.
Link copied to clipboard
public abstract List<Element> findElementsByTagName(String tagName)
Returns an immutable list of the Element objects found in the current search context by the given tagName.
Link copied to clipboard
public abstract Optional<Element> focusedElement()
Returns an Optional that contains the currently focused element in the document, otherwise an empty Optional if there is no focused element in this document.
Link copied to clipboard
public abstract Frame frame()
Returns the Frame instance of this document.
Link copied to clipboard
public final Element getByClassName(String className)
public final Element getByClassName(String className)

Returns the first Element found in the current search context by the given className.

Link copied to clipboard
public final Element getByCssSelector(String cssSelector)
public final Element getByCssSelector(String cssSelector)

Returns the first Element found in the current search context by the given cssSelector.

Link copied to clipboard
public final Element getById(String id)
public final Element getById(String id)

Returns the first Element found in the current search context by the given id.

Link copied to clipboard
public final Element getByName(String name)
public final Element getByName(String name)

Returns the first Element found in the current search context by the given name.

Link copied to clipboard
public final Element getByTagName(String tagName)
public final Element getByTagName(String tagName)

Returns the first Element found in the current search context by the given tagName.

Link copied to clipboard
public abstract boolean insertChild(Node node, Node beforeNode)
Inserts the given node before the given beforeNode as a child of the current node.
Link copied to clipboard
public abstract Optional<Node> nextSibling()
Returns an Optional that contains the next node in the document tree if such a node exists, otherwise returns an empty Optional.
Link copied to clipboard
public abstract String nodeName()
Returns a string that represents the node name in the UTF8 format.
Link copied to clipboard
public abstract String nodeValue()
Returns a string that represents the node value.
public abstract void nodeValue(String value)
Updates the node value with the given new value.
Link copied to clipboard
public abstract Optional<Node> parent()
Returns an Optional that contains the parent of this node.
Link copied to clipboard
public abstract Optional<Node> previousSibling()
Returns an Optional that contains the previous node in the document tree if such a node exists, otherwise returns an empty Optional.
Link copied to clipboard
public abstract boolean removeChild(Node childNode)
Removes the given childNode of the current node from the DOM.
Link copied to clipboard
public abstract void removeEventListener(EventType eventType, Observer<Event> listener, boolean useCapture)
Removes the given listener from the event target.
Link copied to clipboard
public abstract boolean replaceChild(Node newNode, Node oldNode)
Replaces the given child oldNode of the current node with the given newNode.
Link copied to clipboard
public abstract String textContent()
Returns the text content of the current node and its descendants.
public abstract void textContent(String textContent)
Removes all the current node children and replaces them with a single text node with the given textContent.
Link copied to clipboard
public abstract NodeType type()
Returns the node type.
Link copied to clipboard
public abstract String xPath()
Returns a string that represents XPath to the current Node or an empty string if it is not available.